package com.group12.liuxinpeng.department.controller;

import com.group12.liuxinpeng.common.control.BaseController;
import com.group12.liuxinpeng.department.service.DepartmentService;
import com.group12.liuxinpeng.mybatis.entity.PtRoleEntity;
import com.group12.liuxinpeng.mybatis.flexigrid.PadingRstType;
import com.group12.liuxinpeng.mybatis.flexigrid.PagingBean;
import com.group12.liuxinpeng.role.entity.SearchRoleEntity;
import com.group12.liuxinpeng.role.service.RoleService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
@Controller
@RequestMapping("/department")
public class DepartmentController extends BaseController {
    private Logger logger = LogManager.getLogger(this.getClass());
    @Resource
    private DepartmentService departmentService;

    @RequestMapping("/departmentPage")
    public String rolePage(){
        return "department/departmentPage";
    }

    @RequestMapping("/addDepartment")
    @ResponseBody
    public String addDepartment(String depUuid, String belongCenter, String branchName, String organUuid){
        logger.info("depUuid" + depUuid);
        logger.info("belongCenter" + belongCenter);
        logger.info("branchName" + branchName);
        logger.info("organUuid" + organUuid);
        departmentService.addDepartment(depUuid,belongCenter,branchName,organUuid);
        return getSuccessMessage("department.add.success");
    }

    @RequestMapping("/delDepartment")
    @ResponseBody
    public String delDepartment(String depUuid){
        logger.info("depUuid" + depUuid);
        departmentService.delDepartment(depUuid);
        return  getSuccessMessage("department.del.success");
    }

}
